home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / program / 317 / asmsrc / gdb-file.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-10-20  |  2.3 KB  |  93 lines

  1. /* gdb_file.c -o/s specific- */
  2.  
  3. /* Copyright (C) 1987 Free Software Foundation, Inc.
  4.  
  5. This file is part of Gas, the GNU Assembler.
  6.  
  7. The GNU assembler is distributed in the hope that it will be
  8. useful, but WITHOUT ANY WARRANTY.  No author or distributor
  9. accepts responsibility to anyone for the consequences of using it
  10. or for whether it serves any particular purpose or works at all,
  11. unless he says so in writing.  Refer to the GNU Assembler General
  12. Public License for full details.
  13.  
  14. Everyone is granted permission to copy, modify and redistribute
  15. the GNU Assembler, but only under the conditions described in the
  16. GNU Assembler General Public License.  A copy of this license is
  17. supposed to have been given to you along with the GNU Assembler
  18. so you can know your rights and responsibilities.  It should be
  19. in a file named COPYING.  Among other things, the copyright
  20. notice and this notice must be preserved on all copies.  */
  21.  
  22. #include <stdio.h>
  23.  
  24. #ifdef atarist
  25. #include <types.h>
  26. #include <stat.h>
  27. #else
  28. #include <sys/types.h>
  29. #include <sys/stat.h>
  30. #endif
  31.  
  32. static long file_len;
  33. static FILE *file;
  34. extern long get_len();
  35.  
  36.  
  37. void
  38. gdb_file_begin ()
  39. {
  40. }
  41.  
  42. void
  43. gdb_file_end()
  44. {
  45. }
  46.  
  47. long int            /* Open file, return size. 0: failed. */
  48. gdb_file_size (filename)
  49. char *filename;
  50. {
  51.   struct stat stat_buf;
  52.   void as_perror();
  53.  
  54.   file= fopen (filename, "r");
  55.   if (file == (FILE *)NULL)
  56.     {
  57.       as_perror ("Can't read GDB symbolic information file", filename);
  58.       file_len=0;
  59.     } else {
  60. #ifdef atarist
  61.     (void)stat (filename, &stat_buf);
  62. #else
  63.     (void)fstat (fileno(file), &stat_buf);
  64. #endif
  65.     file_len=stat_buf . st_size;
  66.     }
  67.   return ((long int)file_len );
  68. }
  69.  
  70. void                /* Read the file, don't return if failed. */
  71. gdb_file_read (buffer, filename)
  72.      char *    buffer;
  73.      char *    filename;
  74. {
  75.   register off_t    size_wanted;
  76.   void as_perror();
  77.  
  78.   size_wanted = file_len;
  79.   if (fread (buffer, size_wanted, 1, file) != 1)
  80.     {
  81.       as_perror ("Can't read GDB symbolic info file", filename);
  82.       as_fatal ("Failed to read %ld. chars of GDB symbolic information",
  83.         size_wanted);
  84.     }
  85.   if (fclose(file)==EOF)
  86.     {
  87.       as_perror ("Can't close GDB symbolic info file", filename);
  88.       as_fatal ("I quit in disgust");
  89.     }
  90. }
  91.  
  92. /* end: gdb_file.c */
  93.